<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 5. 检测字符串是否为为空，有提示
    // 6. 检测字符串是否以数字开头
    // 7. 检测字符串长度是否在6~20之间
    var str = " 1asba55lj4565janfanfoaf"
    for (i = 0; i < str.length; i++) {
        if ((typeof str[i]) == undefined) {
            console.log("字符串为空")
            break;
        }
        console.log("字符不为空")
    }
    if ((typeof str[0]) == Number) {
        console.log("以数字开头")
    }
    else{
        console.log("不以数字开头")
    }
    if(str.length>6 &&str.length<20){
        console.log("字符串长度在6~20之间")
    }
    else{
        console.log("字符串长度不在6~20之间")
    }

</script>

</html>